//
//  TMCheckActionView.m
//  国学商家管理
//
//  Created by Tao Li on 2018/6/21.
//  Copyright © 2018年 mac. All rights reserved.
//

#import "TMCheckActionView.h"

@implementation TMCheckActionView

- (IBAction)didSelectAction:(UISegmentedControl *)sender {
    if (self.block) {
        self.block(sender.selectedSegmentIndex);
    }
}
-(void)setIsCheck:(NSInteger)isCheck{
    _isCheck = isCheck;
}
-(void)awakeFromNib{
    [super awakeFromNib];
    self.fristView.layer.borderColor = [UIColor hx_colorWithHexRGBAString:@"#05B48D"].CGColor;
    self.fristView.layer.borderWidth = 0.5f;
    self.secondView.layer.borderColor = [UIColor hx_colorWithHexRGBAString:@"#05B48D"].CGColor;
    self.secondView.layer.borderWidth = .5f;
    NSInteger index = [[NSUserDefaults standardUserDefaults] integerForKey:@"indexss"];
    if (index == 2) {
        [self.secondView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"#DEF2EE"]];
        [self.fristView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"FFFFFF"]];
    }
    if(index == 1)
    {
        [self.fristView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"#DEF2EE"]];
        [self.secondView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"FFFFFF"]];
    }
}
- (IBAction)backAction:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected == YES) {
        [self.secondView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"#DEF2EE"]];
        [self.fristView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"FFFFFF"]];
        sender.selected = NO;
    }else if(sender.selected == NO)
    {
        [self.fristView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"#DEF2EE"]];
        [self.secondView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"FFFFFF"]];
        sender.selected = YES;
    }
    [self layoutSubviews];
    if (self.block) {
        self.block(sender.tag-10);
    }
}
- (IBAction)checkAction:(UIButton *)sender {
    sender.selected = !sender.selected;
    if (sender.selected == YES) {
        [self.fristView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"#DEF2EE"]];
        [self.secondView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"FFFFFF"]];
        sender.selected = NO;
    }else{
        [self.secondView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"#DEF2EE"]];
        [self.fristView setBackgroundColor:[UIColor hx_colorWithHexRGBAString:@"FFFFFF"]];
        sender.selected = YES;
    }
    [self layoutSubviews];
    
    if (self.block) {
        self.block(sender.tag-10);
    }
}

@end
